package com.spi.soconversion.base.definition;

import com.spi.soconversion.util.SOCConstants;
import com.spi.soconversion.util.SOCUtility;
import com.spi.soconversion.util.XMLAttributeConstants;
import com.spi.soconversion.util.XMLTagConstants;

public class SOCOrderLineItem {

	private String itemID;
	private String itemShortDesc;
	private String productClass;
	private String unitOfMeasure;
	private String productLine;

	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer();

		sb.append(XMLTagConstants.START_TAG_ITEM);
		sb.append(SOCConstants.BLANK_STRING);
		
		sb.append(SOCUtility.getAttribute(XMLAttributeConstants.ITEM_ID,	getItemID()));
		sb.append(SOCConstants.BLANK_STRING);
		
		sb.append(SOCUtility.getAttribute(XMLAttributeConstants.ITEM_SHORT_DESC, SOCUtility.replaceXMLSpecialCharacters(getItemShortDesc())));
		sb.append(SOCConstants.BLANK_STRING);
		
		sb.append(SOCUtility.getAttribute(XMLAttributeConstants.PRODUCT_CLASS,getProductClass()));
		sb.append(SOCConstants.BLANK_STRING);
		
		sb.append(SOCUtility.getAttribute(XMLAttributeConstants.UNIT_OF_MEASURE, getUnitOfMeasure()));
		sb.append(SOCConstants.BLANK_STRING);
		
		sb.append(SOCUtility.getAttribute(XMLAttributeConstants.PRODUCT_LINE, getProductLine()));
		sb.append(SOCConstants.BLANK_STRING);
		
		sb.append(SOCConstants.CLOSING_XML_TAG);
		sb.append(SOCConstants.NEW_LINE);

		sb.append(XMLTagConstants.END_TAG_ITEM);

		return sb.toString();

	}

	public String getItemID() {
		return SOCUtility.checkNull(itemID);
	}

	public void setItemID(String itemID) {
		this.itemID = itemID;
	}

	public String getItemShortDesc() {
		itemShortDesc= SOCUtility.checkNull(itemShortDesc);
		if(itemShortDesc.length()>100)
		{
			itemShortDesc = itemShortDesc.substring(0, 100);
		}
		return itemShortDesc ;
	}

	public void setItemShortDesc(String itemShortDesc) {
		this.itemShortDesc = itemShortDesc;
	}

	public void setProductClass(String productClass) {
		this.productClass = productClass;
	}

	public String getProductClass() {
		return SOCUtility.checkNull(productClass);
	}

	public String getUnitOfMeasure() {
		return SOCUtility.checkNull(unitOfMeasure);
	}

	public void setUnitOfMeasure(String unitOfMeasure) {
		this.unitOfMeasure = unitOfMeasure;
	}

	public String getProductLine() {
		return SOCUtility.checkNull(productLine);
	}

	public void setProductLine(String productLine) {
		this.productLine = productLine;
	}
}
